import java.util.Scanner;

    public class MatrixSum {
        public static void main(String[] args) {
            int[][] matrix1 = new int[3][4];
            int[][] matrix2 = new int[3][4];
            int[][] result = new int[3][4];

            Scanner scanner = new Scanner(System.in);

            System.out.println("请输入第一个矩阵的元素:");
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 4; j++) {
                    System.out.print("第 " + (i + 1) + " 行，第 " + (j + 1) + " 列: ");
                    matrix1[i][j] = scanner.nextInt();
                }
            }

            System.out.println("请输入第二个矩阵的元素:");
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 4; j++) {
                    System.out.print("第 " + (i + 1) + " 行，第 " + (j + 1) + " 列: ");
                    matrix2[i][j] = scanner.nextInt();
                }
            }

            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 4; j++) {
                    result[i][j] = matrix1[i][j] + matrix2[i][j];
                }
            }

            System.out.println("两个矩阵之和为:");
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 4; j++) {
                    System.out.print(result[i][j] + " ");
                }
                System.out.println();
            }

            scanner.close();
        }
    }

